package com.mayuhao.time.date;

import lombok.Data;

import java.util.Date;

@Data
public class MyDateImpl implements MyDateFunction {
    private Date onlyTime;

    private int add_ymd;
    private int add_hms;
    private int add_ST;

    private long All_ST_ymd;
    private long All_ST_hms;
    private long All_ST;

    @Override
    public void setMyDate(String year, String month, String day, String hour, String minute, String ss) {
        onlyTime = new Date(Integer.parseInt(year) - 1900,
                Integer.parseInt(month) - 1,
                Integer.parseInt(day),
                Integer.parseInt(hour),
                Integer.parseInt(minute),
                Integer.parseInt(ss));
    }

    @Override
    public long getMyDateYmd() {
        add_ymd += 1000;
        return (onlyTime.getTime() + add_ymd - 1000);
    }

    @Override
    public long getMyDateHms() {
        add_hms += 1000;
        return (onlyTime.getTime() + add_hms - 1000);

    }

    @Override
    public void clearAdd() {
        add_ymd = 0;
        add_hms = 0;
    }

    public void setNowDateST(int st) {
        Date date = new Date();
        All_ST = date.getTime() + st;
    }

    public long getNowDateYmd() {
        All_ST_ymd += 1000;
        return (All_ST + All_ST_ymd - 1000);
    }

    public long getNowDateHms() {
        All_ST_hms += 1000;
        return (All_ST + All_ST_hms - 1000);

    }

    public void clearSTAdd() {
        All_ST_hms = 0;
        All_ST_ymd = 0;
    }

}
